feat(conversationsStore) - cache conversations to BrowserStorage#10203
feat(conversationsStore) - cache conversations to BrowserStorage#10203
Conversation
ShGKme
left a comment
There was a problem hiding this comment.
Tested, works fine. Only some naming preferences.
Checked that LS is pruned on logout, not security issues β
From the UX side: after reload, a user sees an old conversations list with old last messages. That could be confusing. Should we add any small load indicator?
BrowserStorage is reused by tabs. If we store conversations in the browser storage, we should do it only once.
Currently it is used only for initialization. But if we open 5 tabs with Talk, then we have 5 apps with 5 conversation re-fetchings and 5 parallel updating localStorage. The most optimal solution here could be to run re-fetching only on one tab/worker and listen to the storage windows event or BroadcastChannel.
|
Upd: instead of shared worker, it could be easier and better for browser support to use Web Locks API |
|
Notes about using Web Locks API here. We don't have actually a "resource" that we want to block. But we can use a Leader pattern. Then we can create a helper like async function onTalkLeaderTab(() => {
// Promise of waiting to be a leader
return new Promise((resolve) =>
// Request "being a leader"
navigator.locks.request('talk:leader', () => {
// Since we got this "resource" this tab is a leader. Resolve promise
resolve()
// Infinity promise, resource is blocked forever, while tab is not closed
return new Promise(() => {})
}
}
onTalkLeaderTab()
.then(() => {
// Now we are the leader
// Start the setInterval for re-fetching or anything
})One important thing: it only works with HTTPS Then we can use the |
3263f12 to
b12044b
Compare
b12044b to
2b2cdb2
Compare
ShGKme
left a comment
There was a problem hiding this comment.
Tested, everything seems to work fine. Tested with 2-3 tabs, with changing leader, creating new conversations, deleting conversations.
|
Follow-up: because x-talk-hash header is checked not in any HTTP response, but only in re-fetching conversations for the |
d9aab00 to
8a94079
Compare
Rebased, follow-up fixed with additional broadcasted message specifically for talk hash. |
112a2a4 to
358ea29
Compare
β¦serStorage Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
f9f8028 to
7d86c4d
Compare
β¦ery 30 seconds only from one source Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
7d86c4d to
2bd8ce1
Compare
|
Follow-ups:
|
|
/backport to stable27 |

βοΈ Resolves
patchConversations()action, which is called approx. every 30 seconds/apps/spreed/not-foundπΌοΈ Screenshots
π§ Tasks
π Checklist
docs/has been updated or is not required